package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.Questionario;

@SuppressWarnings("serial")
public class QuestionarioDataModel extends PrimeDataModel<Questionario> {

	public QuestionarioDataModel() {
	}

	public QuestionarioDataModel(Object data) {
		super(data);
	}

	@SuppressWarnings("unchecked")
	@Override
    public Questionario getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<Questionario> questionarios = (List<Questionario>) getWrappedData();
        
        for(Questionario questionario : questionarios) {
        	String id = ""+questionario.getIdQuestionario();
            if(id.equals(rowKey))
                return questionario;
        }
        
        return null;
    }

    @Override
    public String getRowKey(Questionario questionario) {
        return ""+questionario.getIdQuestionario();
    }
}
